home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
option.exe
/
TEST.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-10-25
|
2KB
|
98 lines
#define Uses_TApplication
#define Uses_THeapApp
#define Uses_TMenuBar
#define Uses_TSubMenu
#define Uses_TMenuItem
#define Uses_TEvent
#define Uses_TKeys
#define Uses_TDialog
#define Uses_TCollection
#define Uses_TOption
#define Uses_TInputLine
#define Uses_TLabel
#define Uses_TDeskTop
#include <tv.h>
#include "TOption.h"
#include "THeapApp.h"
const cmTest = 100;
class TMyApp : public THeapApp
{
public:
TMyApp();
static TMenuBar *initMenuBar( TRect r );
virtual void handleEvent( TEvent& event );
};
class TStrCollection : public TCollection
{
public:
TStrCollection( ccIndex aLimit, ccIndex aDelta ) :
TCollection(aLimit, aDelta) {}
virtual void *readItem( ipstream& )
{ return this; }
virtual void writeItem( void *, opstream& )
{}
};
TMyApp::TMyApp() :
TProgInit( &TMyApp::initStatusLine,
&TMyApp::initMenuBar,
&TMyApp::initDeskTop
)
{
}
TMenuBar *TMyApp::initMenuBar( TRect r )
{
r.b.y = r.a.y+1;
return new TMenuBar( r,
*new TSubMenu( "~T~est", 0 )+
*new TMenuItem( "~D~ialog with TOption", cmTest, kbNoKey )+
*new TMenuItem( "E~x~it", cmQuit, kbAltX, hcNoContext, "Alt-X" )
);
}
void TMyApp::handleEvent( TEvent& event )
{
TApplication::handleEvent( event );
if( event.what == evCommand && event.message.command == cmTest )
{
TDialog *pd = new TDialog( TRect(0,0,50,11), "Test Dialog" );
if( validView(pd) != 0 )
{
TInputLine *pl = new TInputLine( TRect(17,3,44,4), 25 );
pd->insert( pl );
pd->insert( new TLabel(TRect(3,3,17,4), "How are you?", pl) );
TStrCollection *pc = new TStrCollection( 5, 0 );
pc->insert( newStr( "Great!" ) );
pc->insert( newStr("Pretty good") );
pc->insert( newStr("So so") );
pc->insert( newStr("I've had better days") );
pc->insert( newStr("Rotten") );
pd->insert( new TOption(TRect(44,3,47,4), pl, pc) );
pd->options |= ofCentered;
deskTop->execView( pd );
destroy(pd);
destroy(pc);
}
clearEvent(event);
}
}
int main()
{
TMyApp app;
app.run();
app.shutDown();
return 0;
}